
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Interrupts &#8212; Freedom Metal v201905 documentation</title>
    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="ITIM" href="itim.html" />
    <link rel="prev" title="GPIO" href="gpio.html" />
   
  <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <div class="section" id="interrupts">
<h1>Interrupts<a class="headerlink" href="#interrupts" title="Permalink to this headline">¶</a></h1>
<p>API for registering and manipulating interrupts. </p>
<div class="breathe-sectiondef docutils container">
<p class="breathe-sectiondef-title rubric">Typedefs</p>
<dl class="type">
<dt id="_CPPv317metal_vector_mode">
<span id="_CPPv217metal_vector_mode"></span><span id="metal_vector_mode"></span><span class="target" id="interrupt_8h_1a12da577bb3179597221662c5589561b3"></span><em class="property">typedef </em><em class="property">enum</em> <a class="reference internal" href="#_CPPv318metal_vector_mode_" title="metal_vector_mode_">metal_vector_mode_</a> <code class="descname">metal_vector_mode</code><a class="headerlink" href="#_CPPv317metal_vector_mode" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Possible mode of interrupts to operate. </p>
</dd></dl>

<dl class="type">
<dt id="_CPPv325metal_interrupt_handler_t">
<span id="_CPPv225metal_interrupt_handler_t"></span><span id="metal_interrupt_handler_t"></span><span class="target" id="interrupt_8h_1acf581f8608907e67e50300eef23a130b"></span><em class="property">typedef </em>void (*<code class="descname">metal_interrupt_handler_t</code>)<span class="sig-paren">(</span>int, void *<span class="sig-paren">)</span><a class="headerlink" href="#_CPPv325metal_interrupt_handler_t" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Function signature for interrupt callback handlers. </p>
</dd></dl>

</div>
<div class="breathe-sectiondef docutils container">
<p class="breathe-sectiondef-title rubric">Enums</p>
<dl class="type">
<dt id="_CPPv318metal_vector_mode_">
<span id="_CPPv218metal_vector_mode_"></span><span id="metal_vector_mode_"></span><span class="target" id="interrupt_8h_1ac60eddab23447dc04711785118af2728"></span><em class="property">enum </em><code class="descname">metal_vector_mode_</code><a class="headerlink" href="#_CPPv318metal_vector_mode_" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Possible mode of interrupts to operate. </p>
<p><em>Values:</em></p>
<dl class="enumerator">
<dt id="_CPPv317METAL_DIRECT_MODE">
<span id="_CPPv217METAL_DIRECT_MODE"></span><span class="target" id="interrupt_8h_1ac60eddab23447dc04711785118af2728ad924f2ea83b99b7d5be2e042e88c6dbd"></span><code class="descname">METAL_DIRECT_MODE</code> = 0<a class="headerlink" href="#_CPPv317METAL_DIRECT_MODE" title="Permalink to this definition">¶</a><br /></dt>
<dd></dd></dl>

<dl class="enumerator">
<dt id="_CPPv317METAL_VECTOR_MODE">
<span id="_CPPv217METAL_VECTOR_MODE"></span><span class="target" id="interrupt_8h_1ac60eddab23447dc04711785118af2728a4287274b1ef3c4a1a5b40ee32740e522"></span><code class="descname">METAL_VECTOR_MODE</code> = 1<a class="headerlink" href="#_CPPv317METAL_VECTOR_MODE" title="Permalink to this definition">¶</a><br /></dt>
<dd></dd></dl>

<dl class="enumerator">
<dt id="_CPPv327METAL_SELECTIVE_VECTOR_MODE">
<span id="_CPPv227METAL_SELECTIVE_VECTOR_MODE"></span><span class="target" id="interrupt_8h_1ac60eddab23447dc04711785118af2728a2a0f324727404e6d792bb629b532388e"></span><code class="descname">METAL_SELECTIVE_VECTOR_MODE</code> = 2<a class="headerlink" href="#_CPPv327METAL_SELECTIVE_VECTOR_MODE" title="Permalink to this definition">¶</a><br /></dt>
<dd></dd></dl>

<dl class="enumerator">
<dt id="_CPPv326METAL_HARDWARE_VECTOR_MODE">
<span id="_CPPv226METAL_HARDWARE_VECTOR_MODE"></span><span class="target" id="interrupt_8h_1ac60eddab23447dc04711785118af2728a4d512f09eb589d9ffd8444706569f9e1"></span><code class="descname">METAL_HARDWARE_VECTOR_MODE</code> = 3<a class="headerlink" href="#_CPPv326METAL_HARDWARE_VECTOR_MODE" title="Permalink to this definition">¶</a><br /></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="breathe-sectiondef docutils container">
<p class="breathe-sectiondef-title rubric">Functions</p>
<dl class="function">
<dt id="_CPPv320metal_interrupt_initP15metal_interrupt">
<span id="_CPPv220metal_interrupt_initP15metal_interrupt"></span><span id="metal_interrupt_init__metal_interruptP"></span><span class="target" id="interrupt_8h_1a8bb69d1c3f0a58fbbe9f849c2dd5d0f6"></span>void <code class="descname">metal_interrupt_init</code><span class="sig-paren">(</span><em class="property">struct</em> <a class="reference internal" href="#_CPPv315metal_interrupt" title="metal_interrupt">metal_interrupt</a> *<em>controller</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv320metal_interrupt_initP15metal_interrupt" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Initialize a given interrupt controller. </p>
<p>Initialize a given interrupt controller. This function must be called before any interrupts are registered or enabled with the handler. It is invalid to initialize an interrupt controller more than once.</p>
<p><dl class="docutils">
<dt><strong>Parameters</strong></dt>
<dd><ul class="breatheparameterlist first last simple">
<li><code class="docutils literal notranslate"><span class="pre">controller</span></code>: The handle for the interrupt controller </li>
</ul>
</dd>
</dl>
</p>
</dd></dl>

<dl class="function">
<dt id="_CPPv332metal_interrupt_register_handlerP15metal_interrupti25metal_interrupt_handler_tPv">
<span id="_CPPv232metal_interrupt_register_handlerP15metal_interrupti25metal_interrupt_handler_tPv"></span><span id="metal_interrupt_register_handler__metal_interruptP.i.metal_interrupt_handler_t.voidP"></span><span class="target" id="interrupt_8h_1a308bebb1f3baa79e140f62ed5c15637a"></span>int <code class="descname">metal_interrupt_register_handler</code><span class="sig-paren">(</span><em class="property">struct</em> <a class="reference internal" href="#_CPPv315metal_interrupt" title="metal_interrupt">metal_interrupt</a> *<em>controller</em>, int <em>id</em>, <a class="reference internal" href="#_CPPv325metal_interrupt_handler_t" title="metal_interrupt_handler_t">metal_interrupt_handler_t</a> <em>handler</em>, void *<em>priv_data</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv332metal_interrupt_register_handlerP15metal_interrupti25metal_interrupt_handler_tPv" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Register an interrupt handler. </p>
<p><dl class="docutils">
<dt><strong>Return</strong></dt>
<dd>0 upon success </dd>
<dt><strong>Parameters</strong></dt>
<dd><ul class="breatheparameterlist first last simple">
<li><code class="docutils literal notranslate"><span class="pre">controller</span></code>: The handle for the interrupt controller </li>
<li><code class="docutils literal notranslate"><span class="pre">id</span></code>: The interrupt ID to register </li>
<li><code class="docutils literal notranslate"><span class="pre">handler</span></code>: The interrupt handler callback </li>
<li><code class="docutils literal notranslate"><span class="pre">priv_data</span></code>: Private data for the interrupt handler </li>
</ul>
</dd>
</dl>
</p>
</dd></dl>

<dl class="function">
<dt id="_CPPv322metal_interrupt_enableP15metal_interrupti">
<span id="_CPPv222metal_interrupt_enableP15metal_interrupti"></span><span id="metal_interrupt_enable__metal_interruptP.i"></span><span class="target" id="interrupt_8h_1a783a6d5804e097dad0a4434a058e45de"></span>int <code class="descname">metal_interrupt_enable</code><span class="sig-paren">(</span><em class="property">struct</em> <a class="reference internal" href="#_CPPv315metal_interrupt" title="metal_interrupt">metal_interrupt</a> *<em>controller</em>, int <em>id</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv322metal_interrupt_enableP15metal_interrupti" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Enable an interrupt. </p>
<p><dl class="docutils">
<dt><strong>Return</strong></dt>
<dd>0 upon success </dd>
<dt><strong>Parameters</strong></dt>
<dd><ul class="breatheparameterlist first last simple">
<li><code class="docutils literal notranslate"><span class="pre">controller</span></code>: The handle for the interrupt controller </li>
<li><code class="docutils literal notranslate"><span class="pre">id</span></code>: The interrupt ID to enable </li>
</ul>
</dd>
</dl>
</p>
</dd></dl>

<dl class="function">
<dt id="_CPPv323metal_interrupt_disableP15metal_interrupti">
<span id="_CPPv223metal_interrupt_disableP15metal_interrupti"></span><span id="metal_interrupt_disable__metal_interruptP.i"></span><span class="target" id="interrupt_8h_1a3f1ed02d57dd231db5c92945e0a347e8"></span>int <code class="descname">metal_interrupt_disable</code><span class="sig-paren">(</span><em class="property">struct</em> <a class="reference internal" href="#_CPPv315metal_interrupt" title="metal_interrupt">metal_interrupt</a> *<em>controller</em>, int <em>id</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv323metal_interrupt_disableP15metal_interrupti" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Disable an interrupt. </p>
<p><dl class="docutils">
<dt><strong>Return</strong></dt>
<dd>0 upon success </dd>
<dt><strong>Parameters</strong></dt>
<dd><ul class="breatheparameterlist first last simple">
<li><code class="docutils literal notranslate"><span class="pre">controller</span></code>: The handle for the interrupt controller </li>
<li><code class="docutils literal notranslate"><span class="pre">id</span></code>: The interrupt ID to disable </li>
</ul>
</dd>
</dl>
</p>
</dd></dl>

<dl class="function">
<dt id="_CPPv329metal_interrupt_vector_enableP15metal_interrupti17metal_vector_mode">
<span id="_CPPv229metal_interrupt_vector_enableP15metal_interrupti17metal_vector_mode"></span><span id="metal_interrupt_vector_enable__metal_interruptP.i.metal_vector_mode"></span><span class="target" id="interrupt_8h_1a2535af198e205b152e6794ac9fe9c41c"></span>int <code class="descname">metal_interrupt_vector_enable</code><span class="sig-paren">(</span><em class="property">struct</em> <a class="reference internal" href="#_CPPv315metal_interrupt" title="metal_interrupt">metal_interrupt</a> *<em>controller</em>, int <em>id</em>, <a class="reference internal" href="#_CPPv317metal_vector_mode" title="metal_vector_mode">metal_vector_mode</a> <em>mode</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv329metal_interrupt_vector_enableP15metal_interrupti17metal_vector_mode" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Enable an interrupt vector. </p>
<p><dl class="docutils">
<dt><strong>Return</strong></dt>
<dd>0 upon success </dd>
<dt><strong>Parameters</strong></dt>
<dd><ul class="breatheparameterlist first last simple">
<li><code class="docutils literal notranslate"><span class="pre">controller</span></code>: The handle for the interrupt controller </li>
<li><code class="docutils literal notranslate"><span class="pre">id</span></code>: The interrupt ID to enable </li>
<li><code class="docutils literal notranslate"><span class="pre">mode</span></code>: The interrupt mode type to enable </li>
</ul>
</dd>
</dl>
</p>
</dd></dl>

<dl class="function">
<dt id="_CPPv330metal_interrupt_vector_disableP15metal_interrupti">
<span id="_CPPv230metal_interrupt_vector_disableP15metal_interrupti"></span><span id="metal_interrupt_vector_disable__metal_interruptP.i"></span><span class="target" id="interrupt_8h_1ac1c55fc3389c5c83b7488dde8f4c863b"></span>int <code class="descname">metal_interrupt_vector_disable</code><span class="sig-paren">(</span><em class="property">struct</em> <a class="reference internal" href="#_CPPv315metal_interrupt" title="metal_interrupt">metal_interrupt</a> *<em>controller</em>, int <em>id</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv330metal_interrupt_vector_disableP15metal_interrupti" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Disable an interrupt vector. </p>
<p><dl class="docutils">
<dt><strong>Return</strong></dt>
<dd>0 upon success </dd>
<dt><strong>Parameters</strong></dt>
<dd><ul class="breatheparameterlist first last simple">
<li><code class="docutils literal notranslate"><span class="pre">controller</span></code>: The handle for the interrupt controller </li>
<li><code class="docutils literal notranslate"><span class="pre">id</span></code>: The interrupt ID to disable </li>
</ul>
</dd>
</dl>
</p>
</dd></dl>

</div>
<dl class="class">
<dt id="_CPPv315metal_interrupt">
<span id="_CPPv215metal_interrupt"></span><span id="metal_interrupt"></span><span class="target" id="structmetal__interrupt"></span><em class="property">struct </em><code class="descname">metal_interrupt</code><a class="headerlink" href="#_CPPv315metal_interrupt" title="Permalink to this definition">¶</a><br /></dt>
<dd><em>#include &lt;interrupt.h&gt;</em><p>A handle for an interrupt. </p>
</dd></dl>

</div>


          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">Freedom Metal</a></h1>








<h3>Navigation</h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../introduction.html">Introduction to Freedom Metal</a></li>
<li class="toctree-l1"><a class="reference internal" href="../devguide.html">Developer Guide</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../api.html">API Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="button.html">Buttons</a></li>
<li class="toctree-l2"><a class="reference internal" href="cache.html">Caches</a></li>
<li class="toctree-l2"><a class="reference internal" href="clock.html">Clocks</a></li>
<li class="toctree-l2"><a class="reference internal" href="cpu.html">CPU</a></li>
<li class="toctree-l2"><a class="reference internal" href="gpio.html">GPIO</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Interrupts</a></li>
<li class="toctree-l2"><a class="reference internal" href="itim.html">ITIM</a></li>
<li class="toctree-l2"><a class="reference internal" href="led.html">LEDs</a></li>
<li class="toctree-l2"><a class="reference internal" href="lock.html">Locks</a></li>
<li class="toctree-l2"><a class="reference internal" href="memory.html">Memory Enumeration</a></li>
<li class="toctree-l2"><a class="reference internal" href="pmp.html">PMPs</a></li>
<li class="toctree-l2"><a class="reference internal" href="shutdown.html">Shutdown</a></li>
<li class="toctree-l2"><a class="reference internal" href="spi.html">SPIs</a></li>
<li class="toctree-l2"><a class="reference internal" href="switch.html">Switches</a></li>
<li class="toctree-l2"><a class="reference internal" href="timer.html">Timer API</a></li>
<li class="toctree-l2"><a class="reference internal" href="tty.html">TTY</a></li>
<li class="toctree-l2"><a class="reference internal" href="uart.html">UARTs</a></li>
</ul>
</li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="../index.html">Documentation overview</a><ul>
  <li><a href="../api.html">API Reference</a><ul>
      <li>Previous: <a href="gpio.html" title="previous chapter">GPIO</a></li>
      <li>Next: <a href="itim.html" title="next chapter">ITIM</a></li>
  </ul></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2019, SiFive Inc..
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 1.7.5</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.11</a>
      
      |
      <a href="../_sources/apiref/interrupt.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>